package io.scnb.springframework.beans.factory.support;

import io.scnb.springframework.beans.factory.BeansException;
import io.scnb.springframework.beans.factory.config.BeanDefinition;

public class AbstractAutowireCapableBeanFactory extends AbstractBeanFactory{

    @Override
    protected BeanDefinition getBeanDefinition(String name) throws BeansException {
        return null;
    }

    @Override
    protected Object createBean(String beanName, BeanDefinition beanDefinition) throws BeansException {
        Object bean = null;
        try {
            bean = beanDefinition.getBeanClass().newInstance();
        } catch (IllegalAccessException | InstantiationException e) {
            throw new BeansException("Instantiation of bean failed", e);
        }
        // bean实例化之后，存到单例对象的缓存中
        addSingleton(beanName, bean);
        return bean;
    }
}
